package com.test.ch02;

import java.util.List;
import java.util.Objects;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/23
 * @Description:
 */
public class Student {
    /**
     类型：@see Long
     注释：学号
     */

    private Long SchoolNumber;
    /**
     类型：@see String
     注释：学生名字
     */
    private String name;
    /**
     类型：@see String
     注释：学生性别
     */
    private String gender;

    /**
     类型：@see Integer
     注释：学生年龄
     */
    private Integer age;

    /**
     类型：@see List<Course>
     注释：学生所选课程
     */
    private List<Course> courses;

    //全参构造器

    public Student(Long schoolNumber, String name, String gender, Integer age, List<Course> courses) {
        SchoolNumber = schoolNumber;
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.courses = courses;
    }

    //空参构造器

    public Student() {
    }

    //Get、Set方法

    public Long getSchoolNumber() {
        return SchoolNumber;
    }

    public void setSchoolNumber(Long schoolNumber) {
        SchoolNumber = schoolNumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public List<Course> getCourses() {
        return courses;
    }

    public void setCourses(List<Course> courses) {
        this.courses = courses;
    }

    //equals、hashCode方法

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(SchoolNumber, student.SchoolNumber) && Objects.equals(name, student.name) && Objects.equals(gender, student.gender) && Objects.equals(age, student.age) && Objects.equals(courses, student.courses);
    }

    @Override
    public int hashCode() {
        return Objects.hash(SchoolNumber, name, gender, age, courses);
    }

    //toString方法

    @Override
    public String toString() {
        return "Student{" +
                "SchoolNumber=" + SchoolNumber +
                ", name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", age=" + age +
                ", courses=" + courses +
                '}';
    }
}